package com.mytaobao.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.baseproject.imageload.ImageLoaderUtil;
import com.mytaobao.R;
import com.tmall.wireless.tangram.structure.BaseCell;
import com.tmall.wireless.tangram.structure.view.ITangramViewLifeCycle;

/**
 * Created by hp on 2017/7/7.
 */

public class TangramImageView extends FrameLayout implements ITangramViewLifeCycle {

    Context mContext;
    ImageView mImageView;

    public TangramImageView(Context context) {
        super(context);
        init(context);
    }

    public TangramImageView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TangramImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mContext = context;
        inflate(getContext(), R.layout.view_image, this);
        mImageView = (ImageView) findViewById(R.id.iv_image);
    }

    @Override
    public void cellInited(BaseCell cell) {

    }

    @Override
    public void postBindView(BaseCell cell) {
        ImageLoaderUtil.getInstance().with(mContext)
                .load(cell.optStringParam("url"))
                .into(mImageView);
//        ImageUtils.doLoadImageUrl(mImageView, cell.optStringParam("url"));
    }

    @Override
    public void postUnBindView(BaseCell cell) {

    }
}
